﻿Namespace Localization
    <System.Windows.Markup.MarkupExtensionReturnType(GetType(String))> _
    Public Class StringExtension
        Inherits ResourceExtension

        Public Sub New()
            MyBase.New()
        End Sub

        Public Sub New(ByVal key As String)
            MyBase.New(key)
        End Sub

        Public Overrides Function ProvideValue(ByVal serviceProvider As System.IServiceProvider) As Object

            Dim result As String = "[" & Key & "]"
            If ResourceManager Is Nothing And Not String.IsNullOrEmpty(Key) Then
                result = "[No ResourceManager]"
            Else
                Dim data As String = ResourceManager.GetString(Key)
                If Not String.IsNullOrEmpty(data) Then
                    result = data
                End If
            End If
            Return result

        End Function
    End Class
End Namespace
